package com.pb.news.service.impl;

import com.pb.news.dao.NewsDao;
import com.pb.news.entity.News;
import com.pb.news.service.NewsService;
import lombok.Getter;
import lombok.Setter;

import java.sql.SQLException;
import java.util.List;

/**
 * NewsServiceImpl--BDQN_WEB_NEWS
 *
 * @author: Jovi
 * @createTime: 2018-03-23 11:30
 **/
public class NewsServiceImpl implements NewsService {

    @Setter
    @Getter
    private NewsDao newsDao;

    @Override
    public boolean updateNews(News news) {
        return newsDao.update(news);
    }

    @Override
    public boolean addNews(News news) {
        return newsDao.add(news);
    }

    @Override
    public boolean deleteNews(int id) {
        return newsDao.delete(id);
    }

    @Override
    public List<News> getNewsList() {
        return newsDao.getNewsLists();
    }

    @Override
    public News getNewsById(int id) {
        return newsDao.getNewsById(id);
    }

    @Override
    public int getTotalCount() {
        try {
            return newsDao.getTotalCount();
        } catch (SQLException e) {
            e.printStackTrace();
        }
        return 0;
    }

    @Override
    public List<News> getPageNewsList(int pageNo, int pageSize) {
        try {
            return newsDao.getPageNewsList(pageNo,pageSize);
        } catch (SQLException e) {
            e.printStackTrace();
        }
        return null;
    }
}
